<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>spade.pyratemp.TemplateEval</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="spade-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://spade2.googlecode.com">SPADE</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        <a href="spade-module.html">Package&nbsp;spade</a> ::
        <a href="spade.pyratemp-module.html">Module&nbsp;pyratemp</a> ::
        Class&nbsp;TemplateEval
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="spade.pyratemp.TemplateEval-class.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== CLASS DESCRIPTION ==================== -->
<h1 class="epydoc">Class TemplateEval</h1><p class="nomargin-top"><span class="codelink"><a href="spade.pyratemp-pysrc.html#TemplateEval">source&nbsp;code</a></span></p>
<center>
<center>  <map id="uml_class_diagram_for_spade_py_87" name="uml_class_diagram_for_spade_py_87">
<area shape="rect" id="node2364" href="spade.pyratemp.TemplateEval-class.html#__init__" title="spade.pyratemp.TemplateEval.__init__" alt="" coords="48,167,131,185"/>
<area shape="rect" id="node1" href="spade.pyratemp.TemplateEval-class.html" title="PseudoSandbox with some additional functions, which are useful in the template." alt="" coords="36,134,143,191"/>
<area shape="rect" id="node2365" href="spade.pyratemp.PseudoSandbox-class.html#eval_allowed_globals" title="spade.pyratemp.PseudoSandbox.eval_allowed_globals" alt="" coords="17,31,161,49"/>
<area shape="rect" id="node2365" href="spade.pyratemp.PseudoSandbox-class.html#register" title="Add an object to the &quot;allowed eval&#45;globals&quot;." alt="" coords="17,52,161,71"/>
<area shape="rect" id="node2365" href="spade.pyratemp.PseudoSandbox-class.html#compile" title="Compile a python&#45;eval&#45;expression." alt="" coords="17,71,161,89"/>
<area shape="rect" id="node2365" href="spade.pyratemp.PseudoSandbox-class.html#eval" title="Eval a python&#45;eval&#45;expression." alt="" coords="17,89,161,108"/>
<area shape="rect" id="node2" href="spade.pyratemp.PseudoSandbox-class.html" title="A pseudo&#45;eval&#45;sandbox." alt="" coords="5,6,173,114"/>
</map>
  <img src="uml_class_diagram_for_spade_py_87.gif" alt='' usemap="#uml_class_diagram_for_spade_py_87" ismap="ismap" class="graph-without-title" />
</center>
</center>
<hr />
<pre class="literalblock">
PseudoSandbox with some additional functions, which are useful
in the template.

Additional functions:
- &quot;default&quot; calls _default()
- &quot;exists&quot;: calls _exists()

</pre>

<!-- ==================== INSTANCE METHODS ==================== -->
<a name="section-InstanceMethods"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Instance Methods</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-InstanceMethods"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.pyratemp.TemplateEval-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.pyratemp-pysrc.html#TemplateEval.__init__">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.pyratemp.TemplateEval-class.html#_default" class="summary-sig-name" onclick="show_private();">_default</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">expr</span>,
        <span class="summary-sig-arg">default</span>=<span class="summary-sig-default">None</span>)</span><br />
      Return the eval-result of expr or a &quot;fallback&quot;-value.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.pyratemp-pysrc.html#TemplateEval._default">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="spade.pyratemp.TemplateEval-class.html#_exists" class="summary-sig-name" onclick="show_private();">_exists</a>(<span class="summary-sig-arg">self</span>,
        <span class="summary-sig-arg">varname</span>)</span><br />
      Test if a variable exists.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="spade.pyratemp-pysrc.html#TemplateEval._exists">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="spade.pyratemp.PseudoSandbox-class.html">PseudoSandbox</a></code></b>:
      <code><a href="spade.pyratemp.PseudoSandbox-class.html#compile">compile</a></code>,
      <code><a href="spade.pyratemp.PseudoSandbox-class.html#eval">eval</a></code>,
      <code><a href="spade.pyratemp.PseudoSandbox-class.html#register">register</a></code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== CLASS VARIABLES ==================== -->
<a name="section-ClassVariables"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Class Variables</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-ClassVariables"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
  <tr>
    <td colspan="2" class="summary">
    <p class="indent-wrapped-lines"><b>Inherited from <code><a href="spade.pyratemp.PseudoSandbox-class.html">PseudoSandbox</a></code></b>:
      <code><a href="spade.pyratemp.PseudoSandbox-class.html#eval_allowed_globals">eval_allowed_globals</a></code>
      </p>
    </td>
  </tr>
</table>
<!-- ==================== METHOD DETAILS ==================== -->
<a name="section-MethodDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Method Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-MethodDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="__init__"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>)</span>
    <br /><em class="fname">(Constructor)</em>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.pyratemp-pysrc.html#TemplateEval.__init__">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  
  <dl class="fields">
    <dt>Overrides:
        <a href="spade.pyratemp.PseudoSandbox-class.html#__init__">PseudoSandbox.__init__</a>
    </dt>
  </dl>
</td></tr></table>
</div>
<a name="_default"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">_default</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">expr</span>,
        <span class="sig-arg">default</span>=<span class="sig-default">None</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.pyratemp-pysrc.html#TemplateEval._default">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <pre class="literalblock">
Return the eval-result of expr or a &quot;fallback&quot;-value.

Use this in the template to use default-values for optional data.
The default-value is used if 'expr' does not exist/is invalid/results in None.

:Note: the variable-name has to be quoted! (like in eval)

:Example:
    ::
        @! default(&quot;optional_var&quot;,&quot;fallback_value&quot;) !@
        &lt;!--(if default(&quot;optional&quot;,False))--&gt;&quot;YES&quot;&lt;!--(else)--&gt;&quot;NO&quot;&lt;!--(end)--&gt;
        &lt;!--(for i in default(&quot;optional_list&quot;,[]))--&gt;

</pre>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="_exists"></a>
<div class="private">
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">_exists</span>(<span class="sig-arg">self</span>,
        <span class="sig-arg">varname</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="spade.pyratemp-pysrc.html#TemplateEval._exists">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Test if a variable exists.</p>
  <p>This tests if 'varname' exists in the current locals-namespace.</p>
  <p>:Note: the variable-name has to be quoted! (like in eval)</p>
  <p>This only works for single variable names. If you want to test 
  complicated expressions, use i.e. _default. (i.e. 
  _default(&quot;expr&quot;,False))</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="spade-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://spade2.googlecode.com">SPADE</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Wed Aug  1 18:44:55 2012
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
